﻿@{
Layout = "~/Views/Shared/DependenciaLayout.cshtml";
String tituloCab = "";
}

@model orienta.ViewModels.Dependencia
<link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/css/orienta.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/js/niftycube.js")"  type="text/javascript" ></script>
<script src="@Url.Content("~/js/funciones.js")"  type="text/javascript" ></script>
<script src="@Url.Content("~/js/solicitud.js")"  type="text/javascript" ></script>
<script src="@Url.Content("~/js/calendario.js")" type="text/javascript" ></script>
<script src="@Url.Content("~/js/ajax.js")" type="text/javascript" ></script>
<script src="@Url.Content("~/js/midis.js")" type="text/javascript" ></script>        
<script src="@Url.Content("~/js/wick.js")" type="text/javascript" ></script>        
<link href="@Url.Content("~/css/wick.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.9.1.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui.js")" type="text/javascript"></script>
<script src="@Url.Content("~/js/dependencias.js")" type="text/javascript"></script>

<script type="text/javascript">
    var dataDependencia;
    window.onload = function () {
        cargarAutoCompleteDependenciaRegion(1);
        calendarioFechaInicio('#dtFecInic');
        calendarioFechaInicio('#dtFecFin');
    }
</script>
@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
<center>
         <table width="100%" border="0" cellpadding="0" cellspacing="0" >
    <tbody class="tituloOpcion">
        <tr><td align="center" style="background-color: #FFFFFF;"><img src="../images/space.gif" width="1" height="2" /></td></tr>
        <tr><td align="right" style="height: 16px;">REGISTRO Y CONSULTA DE DEPENDENCIAS</td></tr>
        <tr><td align="center" style="background-color: #FFFFFF;"><img src="../images/space.gif" width="1" height="2" /></td></tr>
    </tbody>
</table>
         
         
          <div class="tablaInterna1" style="width: 1000px;">
          
          <table cellpadding="10" cellspacing="0" border="0" width="100%">
            <tr>
                <td align="center">
                    <table cellpadding="3" cellspacing="0" border="0" class="tablaPrincipalSin1">
                        <tbody class="tituloTextBold8">
                        <tr>
                            <td align="center">
                            <table cellpadding="0" cellspacing="0" border="0">
                                <tbody class="tituloTextBold8">
                                <tr align="center">
                                    <td>Hijos</td>
                                    <td>Dependencia de Consulta</td>
                                    <td rowspan="2" style="width:50px;">&nbsp;</td>
                                    <td>
                                        <input type="button" name="btnBuscar" class="boton" style="width:80px;"  id="btnBuscar" value="Consultar" onclick="javascript:enviarConsulta();"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td><input id="hijos" name="hijos" type="checkbox" value="S"/></td>
                                    <td>
                                        @Html.TextBoxFor(model => model.depSearch, new { autocomplete = "OFF", records = "1", letra = "", dataSrc = "dataDependencia", size = "52", alt = "nIdeDepSearch", @class = "cajaTextoMayuscula wickEnabledAuto", ondblclick = "javascript:limpiaCaja(this);", onkeypress = "return validaCaracterV2(event);" })
                                        <!--<img src="../images/browse.gif" class="lupita2_MIDIS" alt="VER DEPENDENCIA" onclick="javascript:mostrarDependenciaSearch();" />-->
                                        @Html.HiddenFor(model => model.nIdeDepSearch)
                                    </td>
                                    <td>
                                        <input type="button" name="btnNuevo" class="boton" style="width:80px;" value="Nuevo" onclick="javascript:registrarNuevaDependencia();" />
                                    </td>
                                </tr>
                                    
                                </tbody>                                    
                            </table>
                            </td>
                        </tr>                        
                        </tbody>
                     </table>
                </td>                
                </tr>
                </table>
          </div>        
          

          <div id="divDetalleDepe">
          </div>
          
          <div id="divDependenciaForm" style="display:none">
<center>
            <div style="width: 840px;">
                <table  width="100%" cellpadding="0" border="0"  cellspacing="0">
                    <tr>
                        <td>
                            <table class="tablaPrincipal_MIDIS"  width="100%" cellpadding="3" border="0"  cellspacing="0">
                                <tr>
                                    <td>
                                        <table cellpadding="0" cellspacing="0" border="0"  width="100%">
                                            <tr>
                                                <td>
                                                    <table  class="tablaTitulo_MIDIS" style="width:180PX;" cellpadding="2" cellspacing="0" border="0">
                                                        <tr>
                                                            <td  align="center">
                                                                <div id="general" class="divTitulo_MIDIS" style="width:200PX;">
                                                                    <span style="background-color:#b50055;color:white;">[
                                                                    @if (!string.IsNullOrEmpty(Request["iddep"])) {
                                                                        tituloCab = "EDITAR DEPENDENCIA";
                                                                                   
                                                                    }
                                                                    else {
                                                                        tituloCab = "REGISTRAR NUEVA DEPENDENCIA";
                                                                    }
                                                                    @tituloCab
                                                                    ]</span>
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <table width="100%" class="tablaInterna_MIDIS" cellpadding="0">
                                                        <tr><td>&nbsp;</td></tr>
                                                        <tr>
                                                            <td align="center">
                                                                <table width="99%" border="0" cellpadding="1" cellspacing="0" class="tablaPrincipalSin">
                                                                    <tbody class="tituloTextNormal">
                                                                        <tr align="left">
                                                                            <td>Tipo:</td>
                                                                            <td>:</td>
                                                                            <td>
                                                                            @Html.DropDownList("nIdeTipo", (IEnumerable<SelectListItem>)ViewBag.CategoriaDependencia)
                                                                            @Html.ValidationMessageFor(model => model.nIdeTipo)
                                                                            </td>
                                                                        </tr>
                                                                        <tr align="left">
                                                                            <td>Descripci&oacute;n</td>
                                                                            <td>:</td>
                                                                            <td>
                                                                            @Html.TextBoxFor(model => model.sDescripcion, new { @class = "cajaTextoMayuscula", @maxlength = "100", size = "60", onkeypress = "return validaCaracterV2(event);", onpaste = "return false;" })
                                                                            @Html.ValidationMessageFor(model => model.sDescripcion)
                                                                            </td>
                                                                        </tr>
                                                                        <tr align="left">
                                                                            <td>Regi&oacute;n Geografica</td>
                                                                            <td>:</td>
                                                                            <td>
                                                                            @if (!string.IsNullOrEmpty(Request["iddep"]))
                                                                            {
                                                                                if (ViewBag.idDepRegion > 0) {
                                                                                    
                                                                                    @Html.DropDownList("nIdeDepRegion", (IEnumerable<SelectListItem>)ViewBag.DepRegion)
                                                                                }
                                                                                else
                                                                                {
                                                                                    @Html.DropDownList("nIdeDepRegion", (IEnumerable<SelectListItem>)ViewBag.DepRegion, "--Seleccione Región--", new { onchange = "javascript:onchangeLimpiarDepPadre();" })
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                            @Html.DropDownList("nIdeDepRegion", (IEnumerable<SelectListItem>)ViewBag.DepRegion, "--Seleccione Región--", new { onchange = "javascript:onchangeLimpiarDepPadre();" })
                                                                            }
                                                                            @Html.ValidationMessageFor(model => model.nIdeDepRegion)
                                                                            </td>
                                                                        </tr>
                                                                        <tr align="left">
                                                                            <td>Dependencia Padre</td>
                                                                            <td>:</td>
                                                                            <td>
                                                                            @Html.TextBoxFor(model => model.depPadre, new { autocomplete = "OFF", records = "1", letra = "", dataSrc = "dataDependencia", size = "52", alt = "nIdeDepPadre", @class = "cajaTextoMayuscula wickEnabledAuto", ondblclick = "javascript:limpiaCaja(this);", onkeypress = "return validaCaracterV2(event);" })
                                                                            <img src="@Url.Content("~/images/browse.gif")" class="lupita2_MIDIS" alt="VER DEPENDENCIA" onclick="javascript:mostrarDependenciaCreate();" />
                                                                            @Html.HiddenFor(model => model.nIdeDepPadre)
                                                                            @Html.ValidationMessageFor(model => model.nIdeDepPadre)
                                                                            </td>
                                                                        </tr>
                                                                        <tr align="left">
                                                                            <td>C&oacute;digo</td>
                                                                            <td>:</td>
                                                                            <td>
                                                                            @Html.TextBoxFor(model => model.nCodigo, new { @maxlength = "16", style = "width:180px", onkeypress = "return validarSoloNumeros(event);", })
                                                                            <img src="@Url.Content("~/images/browse.gif")" class="lupita2_MIDIS" alt="VER CODIGOS" onclick="javascript:mostrarDependenciaCodigo();" />
                                                                            @Html.ValidationMessageFor(model => model.nCodigo)
                                                                            </td>
                                                                        </tr>
                                                                        <tr align="left">
                                                                            <td>Siglas</td>
                                                                            <td>:</td>
                                                                            <td>
                                                                            @Html.TextBoxFor(model => model.sSiglas, new { @maxlength = "20", style = "width:180px", onkeypress = "return validaCaracterV2(event);" })
                                                                            @Html.ValidationMessageFor(model => model.sSiglas)
                                                                            </td>
                                                                        </tr>
                                                                        <tr align="left">
                                                                            <td>Selecci&oacute;n</td>
                                                                            <td>:</td>
                                                                            <td>
                                                                            @Html.DropDownList("nSeleccion", ViewBag.List as SelectList)
                                                                            @Html.ValidationMessageFor(model => model.nSeleccion)
                                                                            </td>
                                                                        </tr>
                                                                        <tr align="left">
                                                                            <td>Fecha Inicio Vigencia</td>
                                                                            <td>:</td>
                                                                            <td>
                                                                            @Html.TextBoxFor(model => model.dtFecInic, new { @maxlength = "10", style = "width:80px", ondblclick = "javascript:limpiaCaja(this)" })
                                                                            @Html.ValidationMessageFor(model => model.dtFecInic)
                                                                            </td>
                                                                        </tr>
                                                                        <tr align="left">
                                                                            <td>Fecha Fin Vigencia</td>
                                                                            <td>:</td>
                                                                            <td>
                                                                            @Html.TextBoxFor(model => model.dtFecFin, new { @maxlength = "10", style = "width:80px", ondblclick = "javascript:limpiaCaja(this)" })
                                                                            @Html.ValidationMessageFor(model => model.dtFecFin)
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td colspan="3" align="center">
                                                                                <input type="submit" name="btnRegistrar" class="boton" style="width:80px;" value="Registrar" />
                                                                            </td>
                                                                        </tr>
                                                                        <tr><td colspan="3" >&nbsp;</td></tr>
                                                                        
                                                                    </tbody>
                                                                </table>
                                                        </tr>
                                                        <tr><td>&nbsp;</td></tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr><td>&nbsp;</td></tr>
                            </table>
                        </td>
                    </tr>
                    <tr><td>&nbsp;</td></tr>
                    
                </table>
            </div>
        </center>
</div>
            
        </center>

<input type="hidden" name="iddep" id="iddep" value="@ViewBag.IdDep" />    
                                               if (!string.IsNullOrEmpty(Request["iddep"]))
                                               {
    <script language="javascript" type="text/javascript">
        editarDependencia();
    </script>
                                               }
                                               
                                               if (!string.IsNullOrEmpty(Request["new"]))
                                               {
    <script language="javascript" type="text/javascript">
        registrarNuevaDependencia();
    </script>
                                               }


                                               if (!string.IsNullOrEmpty(ViewBag.Mensaje))
                                               {
    <script language="javascript" type="text/javascript">
        alert('@ViewBag.Mensaje');
    </script>
}


}    



                                                                                
